using System;

namespace QFramework.Example
{
    public class CoinUpgradeItem
    {
        public string Key
        {
            get;
            private set;
        }

        public string Description
        {
            get;
            private set;
        }

        public int Price
        {
            get;
            private set;
        }

        public bool UpgradeFinish
        {
            get;
            set;
        } = false;

        private Action<CoinUpgradeItem> ActionUpgrade;

        private Func<CoinUpgradeItem, bool> FuncCondition;

        public void Upgrade(CoinUpgradeItem item)
        {
            ActionUpgrade?.Invoke(item);
        }

        public bool ConditionCheck()
        {
            if (FuncCondition != null)
            {
                return !UpgradeFinish && FuncCondition.Invoke(this);
            }
            return !UpgradeFinish;
        }

        public CoinUpgradeItem OnKey(string key)
        {
            Key = key;
            return this;
        }

        public CoinUpgradeItem OnDescription(string description)
        {
            Description = description;
            return this;
        }

        public CoinUpgradeItem OnPrice(int price)
        {
            Price = price;
            return this;
        }

        public CoinUpgradeItem OnUpgrade(Action<CoinUpgradeItem> action)
        {
            ActionUpgrade = action;
            return this;
        }

        public CoinUpgradeItem OnCondition(Func<CoinUpgradeItem, bool> func)
        {
            FuncCondition = func;
            return this;
        }


    }
}